const util = require('../../../utils/util.js');
const api = require('../../../config/api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    posts: [],
    pid: 0
  },
  selectPostData: function() {
    let that = this;
    util.request(api.FindPostUrl).then(function(res) {
      if (res.success) {
        that.setData({
          posts: res.data
        });
      }
    });
  },
  goAdd: function() {
    wx.navigateTo({
      url: '/pages/vip/addAddress/addAddress?pid=' + this.data.pid
    })
  },
  selectPost: function(event) {
    let pid = this.data.pid;
    let url = '';
    if (pid == 0) {
      return false;
      //url = '/pages/card/send/send?postId=' + event.currentTarget.dataset.postid
    } else {
      url = '/pages/goods/order/order?postId=' + event.currentTarget.dataset.postid + '&pid=' + pid;
    }
    wx.navigateTo({
      url:url
    })
  },
  onLoad: function(options) {
    if (options.pid) {
      this.setData({
        pid: options.pid
      });
    }
    this.selectPostData();

  }
})